#ifndef __API_MEMORY_H
#define __API_MEMORY_H

#include "bsp_flash.h"
#include "api_valve.h"

#ifdef __cplusplus
 extern "C" {
#endif


/*宏定义表内需要存储参数的falsh起始地址和偏移量*/

#define  MCU_VALVE_ADDR   		 (Sector124_BaseAddr + 0)     /*阀控状态存储，独占一个扇区*/

/* Note: 125 被IAP Flag占用 */

//一下参数均为擦写次数不多的参数
#define  Flash_PARA_STRAT_ADDR   (Sector126_BaseAddr)
#define  MCU_RESET_RECORD_ADDR   (Sector126_BaseAddr + 32)    /*累计复位计数*/

/*以下参数需要平衡磨损保护*/
#define  MCU_WaterVolume_ADDR   (Sector127_BaseAddr)         /*占用整个扇区*/


//#define  METER_NUM_ADDR   		 (Sector126_BaseAddr + 0)	  /*7字节表号*/

#define  METER_NUM_ADDR   		 (0x00001e00)	  // addr @7.7kb 

void API_Memory_Init(void);

void API_Memory_Read_Waterlog(uint16_t *readBuff);
void API_Memory_Write_Waterlog(uint16_t data);

void API_Memory_Read_Restcnt(uint32_t *rst_Cnt);
void API_Memory_Write_Restcnt(uint32_t rst_Cnt);
 
void API_Memory_Write_MeterNum(uint8_t *MeterNum);
void API_Memory_Read_MeterNum(void *MeterNum);

void API_Memory_Read_VALVEStatus(uint8_t *Vstatus);
void API_Memory_Write_VALVEStatus(uint8_t Vstatus);


#endif

